package com.example.administrator.printer.entity;

import android.text.TextUtils;

import com.example.cloudprinter.printer.IFormat;
import com.example.cloudprinter.printer.IPrinterTemplate;

import java.util.List;

/**
 * 订单信息
 */
public class OrderingEntity implements IPrinterTemplate {
    //订单id
    private int order_id;
    //是否已收款 0：未收款，1：已收款
    private int offline_payment;
    //卖家电话
    private String buyer_phone;
    //订单金额
    private String order_amount;
    //产品总价
    private String goods_amount;
    //下单时间
    private String add_time;
    //付款类型
    private String payment_code;
    //付款名称
    private String payment_name;
    //订单状态名称
    private String order_state_name;
    //
    private String trans_state;
    //
    private String gcg_id;
    //
    private String state_desc;
    //订单状态编码
    private String order_state_key;
    //预约时间
    private String apt_time;
    //订单商品名称
    private String order_goods_name;
    //订单编号
    private String order_sn;
    //订单内的商品
    private List<OrderingExtendEntity> extend_order_goods;
    //餐桌号
    private String table_num;
    //是否显示预约
    private int isyuyue;
    //是否显示联系电话
    private int isphone;
    //是否显示餐桌号
    private int isfoodtable;
    //是否显示编辑餐桌
    private int iseditfoodtable;
    //是否在线付款
    private int isonline;
    //优惠信息
    private List<DiscountEntity> order_discount;
    //用餐人数
    private String number_of_people;
    //餐具费
    private String tableware_fee;
    //用户备注
    private String order_message;
    //当天该商家的第几个订单
    private int today_order_num;
    //订单类型
    public int order_type;
    //订单内容
    private String order_content;
    //是否是买家端主动取消订单（线上支付的订单） 1：是，0：否
    private int lock_state;
    //是否是补点订单
    private boolean if_parent_order_id;
    //订单已打印次数
    private String clearing_print_num;
    //是否有未完成消费的补点订单；0：没有，1：有
    private int add_order_state;
    //主订单id
    private int parent_order_id;
    //在线支付订单的退款状态： 3已退款，2退款中，1退款待处理，0无退款需求
    private int cancel_desc;

    public String getClearing_print_num() {
        return clearing_print_num;
    }

    public void setClearing_print_num(String clearing_print_num) {
        this.clearing_print_num = clearing_print_num;
    }

    public boolean isIf_parent_order_id() {
        return if_parent_order_id;
    }

    public void setIf_parent_order_id(boolean if_parent_order_id) {
        this.if_parent_order_id = if_parent_order_id;
    }

    public int getToday_order_num() {
        return today_order_num;
    }

    public void setToday_order_num(int today_order_num) {
        this.today_order_num = today_order_num;
    }

    public int getOrder_id() {
        return order_id;
    }

    public void setOrder_id(int order_id) {
        this.order_id = order_id;
    }

    public int getOffline_payment() {
        return offline_payment;
    }

    public void setOffline_payment(int offline_payment) {
        this.offline_payment = offline_payment;
    }

    public String getBuyer_phone() {
        return buyer_phone;
    }

    public void setBuyer_phone(String buyer_phone) {
        this.buyer_phone = buyer_phone;
    }

    public String getOrder_amount() {
        return order_amount;
    }

    public void setOrder_amount(String order_amount) {
        this.order_amount = order_amount;
    }

    public String getGoods_amount() {
        return goods_amount;
    }

    public void setGoods_amount(String goods_amount) {
        this.goods_amount = goods_amount;
    }

    public String getAdd_time() {
        return add_time;
    }

    public void setAdd_time(String add_time) {
        this.add_time = add_time;
    }

    public String getPayment_code() {
        return payment_code;
    }

    public void setPayment_code(String payment_code) {
        this.payment_code = payment_code;
    }

    public String getPayment_name() {
        return payment_name;
    }

    public void setPayment_name(String payment_name) {
        this.payment_name = payment_name;
    }

    public String getOrder_state_name() {
        return order_state_name;
    }

    public void setOrder_state_name(String order_state_name) {
        this.order_state_name = order_state_name;
    }

    public String getTrans_state() {
        return trans_state;
    }

    public void setTrans_state(String trans_state) {
        this.trans_state = trans_state;
    }

    public String getGcg_id() {
        return gcg_id;
    }

    public void setGcg_id(String gcg_id) {
        this.gcg_id = gcg_id;
    }

    public String getState_desc() {
        return state_desc;
    }

    public void setState_desc(String state_desc) {
        this.state_desc = state_desc;
    }

    public String getOrder_state_key() {
        return order_state_key;
    }

    public void setOrder_state_key(String order_state_key) {
        this.order_state_key = order_state_key;
    }

    public String getApt_time() {
        return apt_time;
    }

    public void setApt_time(String apt_time) {
        this.apt_time = apt_time;
    }

    public String getOrder_goods_name() {
        return order_goods_name;
    }

    public void setOrder_goods_name(String order_goods_name) {
        this.order_goods_name = order_goods_name;
    }

    public String getOrder_sn() {
        return order_sn;
    }

    public void setOrder_sn(String order_sn) {
        this.order_sn = order_sn;
    }

    public List<OrderingExtendEntity> getExtend_order_goods() {
        return extend_order_goods;
    }

    public void setExtend_order_goods(List<OrderingExtendEntity> extend_order_goods) {
        this.extend_order_goods = extend_order_goods;
    }

    public String getTable_num() {
        return table_num;
    }

    public void setTable_num(String table_num) {
        this.table_num = table_num;
    }

    public int getIsyuyue() {
        return isyuyue;
    }

    public void setIsyuyue(int isyuyue) {
        this.isyuyue = isyuyue;
    }

    public int getIsphone() {
        return isphone;
    }

    public void setIsphone(int isphone) {
        this.isphone = isphone;
    }

    public int getIsfoodtable() {
        return isfoodtable;
    }

    public void setIsfoodtable(int isfoodtable) {
        this.isfoodtable = isfoodtable;
    }

    public int getIseditfoodtable() {
        return iseditfoodtable;
    }

    public void setIseditfoodtable(int iseditfoodtable) {
        this.iseditfoodtable = iseditfoodtable;
    }

    public int getIsonline() {
        return isonline;
    }

    public void setIsonline(int isonline) {
        this.isonline = isonline;
    }

    public List<DiscountEntity> getOrder_discount() {
        return order_discount;
    }

    public void setOrder_discount(List<DiscountEntity> order_discount) {
        this.order_discount = order_discount;
    }

    public String getNumber_of_people() {
        return number_of_people;
    }

    public void setNumber_of_people(String number_of_people) {
        this.number_of_people = number_of_people;
    }

    public String getTableware_fee() {
        return tableware_fee;
    }

    public void setTableware_fee(String tableware_fee) {
        this.tableware_fee = tableware_fee;
    }

    public String getOrder_message() {
        return order_message;
    }

    public void setOrder_message(String order_message) {
        this.order_message = order_message;
    }

    public int getOrder_type() {
        return order_type;
    }

    public void setOrder_type(int order_type) {
        this.order_type = order_type;
    }

    public String getOrder_content() {
        return order_content;
    }

    public void setOrder_content(String order_content) {
        this.order_content = order_content;
    }

    public int getLock_state() {
        return lock_state;
    }

    public void setLock_state(int lock_state) {
        this.lock_state = lock_state;
    }

    public int getAdd_order_state() {
        return add_order_state;
    }

    public void setAdd_order_state(int add_order_state) {
        this.add_order_state = add_order_state;
    }

    public int getParent_order_id() {
        return parent_order_id;
    }

    public void setParent_order_id(int parent_order_id) {
        this.parent_order_id = parent_order_id;
    }

    public int getCancel_desc() {
        return cancel_desc;
    }

    public void setCancel_desc(int cancel_desc) {
        this.cancel_desc = cancel_desc;
    }

    private String storeName;

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    /**
     * 获取打印模板内容
     *
     * @param f 指令格式
     * @return
     */
    @Override
    public String getPrintTemplate(IFormat f) {
        String content = f.newline(1);

        content += "走年点餐 *" + getStoreName() + "*";
        content += f.newline(2);

        if (!TextUtils.isEmpty(getTable_num())) {//有餐桌号

            content += f.center(f.big(getTable_num() + "#" + getToday_order_num()));
            content += f.newline(1);

            if (isIf_parent_order_id()) {//补点订单
                content += f.right(f.bold(getTable_num() + "#" + getToday_order_num()));
            }
        } else {//没有餐桌号

            content += f.center(f.big("_______#" + getToday_order_num()));
            content += f.newline(1);

            if (isIf_parent_order_id()) {//补点订单
                content += f.right(f.bold("补"));
                content += f.newline(1);
            }

            content += f.center("您尚未在商家端备注桌号，请您自行备注！");
            content += f.newline(1);
        }

        if (!isIf_parent_order_id()) {//主订单

            content += "订单编号：" + getOrder_sn();
            content += f.newline(1);

        } else {//补点订单

            content += "关联主订单编号：" + getOrder_sn();
            content += f.newline(1);

        }

        content += "顾客电话：" + getBuyer_phone();
        content += f.newline(1);

        content += "*******************************";
        content += f.newline(1);

        content += f.threeColunm("餐品", "数量", "价格", true);

        if (getExtend_order_goods() != null && getExtend_order_goods().size() > 0) {
            for (OrderingExtendEntity goods : getExtend_order_goods()) {

                content += f.threeColunm(goods.getGoods_name(), goods.getGoods_num(),
                        "￥" + goods.getGoods_pay_price(), false);

                if (!TextUtils.isEmpty(goods.getGoods_spec())) {
                    content += goods.getGoods_spec();
                    content += f.newline(1);
                }
            }
        }

        content += "*******************************";
        content += f.newline(1);

        content += f.threeColunm("", "人数", "餐具费", true);

        if (!isIf_parent_order_id()) {//主订单

            content += f.threeColunm("用餐人数",
                    getNumber_of_people(), "￥" + getTableware_fee(), false);

        } else {//补点订单

            content += f.threeColunm("增加用餐人数",
                    getNumber_of_people(), "￥" + getTableware_fee(), false);

        }

        content += "*******************************";
        content += f.newline(1);

        if (getOrder_discount() != null && getOrder_discount().size() > 0) {
            for (DiscountEntity discount : getOrder_discount()) {
                content += f.threeColunm(discount.getTitle(), "", discount.getPrice(), false);
            }
        }

        content += f.newline(1);

        content += f.right("原价：￥" + getGoods_amount());

        if (getIsonline() != 1) {//线下支付
            content += f.right("线下支付：￥" + getOrder_amount());
            content += f.newline(1);
            content += f.center(f.bold("顾客选择线下支付，请您及时收款！"));
            content += f.newline(1);
        } else {//线上支付
            content += f.right("在线实际支付：￥" + getOrder_amount());
            content += f.newline(1);
        }

        if (!TextUtils.isEmpty(getOrder_message())) {
            content += "*******************************";
            content += f.newline(1);
            content += "顾客留言：" + getOrder_message();
            content += f.newline(2);
        }
        return content;
    }
}
